mui.init();
mui.plusReady(function() {
	//	window.addEventListener('refreshdom', function(event) {
	//		console.log(event.detail.val);
	//		userindex.reqcode(event.detail.val);
	//	})
	var userindex = new Vue({
		el: "#app",
		data: {
			data: [],
			postData: {
				p: 1,
				size: 10
			},
			order_status: {
				1: '已确认',
				2: '完成',
				3: '取消'
			},
			shipping_status: {
				0: '待发货',
				1: '已发货',

			}

		},
		mounted: function() {
			var _this = this;
			_this.$nextTick(function() {
				_this.cartView();
			});

		},
		methods: {
			cartView: function() {
				var _this = this;
				console.log(JSON.stringify(_this.postData))
				app.postUrl(apiurl + 'Mall/myOrders.html', _this.postData, function(res) {
					console.log(JSON.stringify(res))
					if(res.status === 1) {
						_this.data = res.data;
						
					}
				});

			},
			refresh: function(done) {
				done();
			},
			infinite: function(done) {
				var _this = this;
				setTimeout(function() {
					_this.postData.p++;
					console.log(JSON.stringify(_this.postData))
					app.postUrl(apiurl + 'Mall/myOrders.html', _this.postData, function(res) {
						console.log(JSON.stringify(res))
						if(res.status === 1) {
							//_this.data = res.data;
							if(res.data.length < 1) {
								setTimeout(function() {
									done(true)
								}, 1000)
								return;
							}
							res.data.forEach(function(value, index) {
								_this.data.push(value);
							});
							setTimeout(function() {
								done()
							})
							//console.log(JSON.stringify(_this.data))
						}
					});

				}, 800);
			},
			openwin: function(urls, uid) {
				mui.openWindow({
					url: urls,
					id: uid,
					extras: {
						name: 'mui' //扩展参数
					}
				});
			},
			vieword: function(gid) {

				mui.openWindow({
					url: 'vieword.html',
					id: 'vieword',
					extras: {
						name: 'mui',
						nid: gid
					}
				});
			},
			quxiao: function(oid) {
				var _this = this;
				var btnArray = [lang('否'), lang('是')];
				mui.confirm('确定要取消本定单吗？', '提示', btnArray, function(e) {
					if(e.index == 1) {
						app.postUrl(apiurl + 'Mall/cancleOrder.html', {
							order_id: oid,
							type: 1
						}, function(res) {
							mui.alert(res.msg);
							_this.cartView();
						});
					} else {
						return;
					}
				})
			},
			shouhuo: function(oid) {
				var _this = this;
				var btnArray = [lang('否'), lang('是')];
				mui.confirm('确定确定收货？', '提示', btnArray, function(e) {
					if(e.index == 1) {
						app.postUrl(apiurl + 'Mall/confirmOrder.html', {
							order_id: oid,
						}, function(res) {
							console.log(JSON.stringify(res))
							mui.alert(res.msg);
							_this.cartView();
						});
					} else {
						return;
					}
				})
			}

		}

	});

	var swiper = new Swiper('.swiper-container', {
		pagination: {
			el: '.swiper-pagination',
		},
		autoplay: true,
	});

});